#ifndef __CarD1_Detect_H
#define __CarD1_Detect_H

#ifdef APM32E10X_HD
	#include "apm32e10x_gpio.h"
	#include "apm32e10x_rcm.h"
	#include "apm32e10x_eint.h"
	#include "apm32e10x_misc.h"
	
#elif defined AT32F403AVGT7
	#include "at32f403a_407_gpio.h"
	#include "at32f403a_407_crm.h"
	#include "at32f403a_407_exint.h"
	#include "at32f403a_407_misc.h"

#else
	#include "apm32f10x_gpio.h"
	#include "apm32f10x_rcm.h"
	#include "apm32f10x_eint.h"
	#include "apm32f10x_misc.h"
#endif

// #include "SQDriConfig.h"



// 车载充电机二极管D1检测 //
#if defined SQDri_EVSEB_7KW || defined SQDri_EVSEB_11KW
	//引脚块1 = 接引脚块A = PC1
	#define CarD1_RTC             RCM_APB2_PERIPH_GPIOC
	#define CarD1_PinPort         GPIOC
	#define CarD1_PinId           GPIO_PIN_1

	#if CarD1_Detect_Tyte == CarD1_Detect_EINT
		//外部中断
		#define CarD1_RCM_EINT        RCM_APB2_PERIPH_AFIO
		#define CarD1_EintPort        GPIO_PORT_SOURCE_C
		#define CarD1_EintPin         GPIO_PIN_SOURCE_1
		#define CarD1_EintLine        EINT_LINE_1
		#define CarD1_Eint_IRQn       EINT1_IRQn
		#define CarD1_Eint_Fun        EINT1_IRQHandler
		                              
	#endif

#else
	//引脚块1 = 接引脚块A = PA7
	#define CarD1_RTC             RCM_APB2_PERIPH_GPIOA
	#define CarD1_PinPort         GPIOA
	#define CarD1_PinId           GPIO_PIN_7
	#if CarD1_Detect_Tyte == CarD1_Detect_EINT
		//外部中断
		#define CarD1_RCM_EINT        RCM_APB2_PERIPH_AFIO
		#define CarD1_EintPort        GPIO_PORT_SOURCE_A
		#define CarD1_EintPin         GPIO_PIN_SOURCE_7
		#define CarD1_EintLine        EINT_LINE_7
		#define CarD1_Eint_IRQn       EINT9_5_IRQn
		#define CarD1_Eint_Fun        EINT9_5_IRQHandler
	#endif

#endif

void carD1_Detect_init(void);

#if CarD1_Detect_Tyte == CarD1_Detect_OCC_Trg
uint8_t carD1_get_level(void);
#endif

#if CarD1_Detect_Tyte == CarD1_Detect_EINT
void carD1_detect_start(void);
void carD1_detect_stop(void);
#endif

#endif

